<?php
require_once dirname(dirname(__FILE__)) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_cinemas.php';
$number = filter_input(INPUT_POST, "number");
?>
<script type="text/javascript">
    $(document).ready(function() {
        $('.ui .item').on('click', function() {
            $('.ui .item').removeClass('active');
            $(this).addClass('active');
        });
        $('.ui.dropdown').dropdown({
            on: 'hover'
        });
    });
</script>
    <form name="form_add_data" id="form_add_data" method="POST" action="?" enctype="multipart/form-data">
<?php
for ($index = 0; $index < $number; $index++) {?>
    <div class="ui form segment form-background">
        <input type="hidden" name="index<?php echo $index; ?>" value="1" />

                            <div class="field">
                                <label for="Name">Title <span class="required">*</span></label>
                                <input name="txt_name<?php echo $index; ?>" value="" placeholder="Name" type="text">
                            </div>
                            
                            <div class="field">
                                <label for="Address">Address <span class="required">*</span></label>
                                <input name="txt_address<?php echo $index; ?>" value="" placeholder="Address" type="text">
                            </div>
                            
                            <div class="field">
                                <label for="Status">City <span class="required">*</span></label>
                                <div class="ui selection dropdown">
                                    <?php 
                                    $city = api_cinemas::get_default_city();
                                    ?>
                                    <input type="hidden" name="ddl_city<?php echo $index; ?>" value="<?php echo $city; ?>">
                                    <div class="text"><?php echo $city; ?></div>
                                    <i class="dropdown icon"></i>
                                    <div class="menu ui transition hidden">
                                      <?php 
                                        $list = api_cinemas::get_all_cities();
                                        $text = "";
                                        if (!empty($list) && count($list) > 0) {
                                            foreach ($list as $item) {?>
                                                <div class="item"><?php echo $item['name']; ?></div>
                                      <?php
                                            } 
                                        }?>
                                    </div>
                                  </div>
                            </div>
                            
                            <div class="field">
                                <label for="Latitude">Latitude <span class="required">*</span></label>
                                <input id="txt_latitude" name="txt_latitude" value="" placeholder="Latitude" type="text">
                            </div>
                            
                            <div class="field">
                                <label for="Longitude">Longitude <span class="required">*</span></label>
                                <input id="txt_longitude" name="txt_longitude" value="" placeholder="Longitude" type="text">
                            </div>
        
                            <div class="field">
                                <label for="Image">Image <span class="required">*</span></label>
                                
                                <input type="file" name="f_image<?php echo $index; ?>" />
                            </div>
    </div>
    <br/>
<?php
}
?>
    <div class="ui form segment form-background">
        <input type="hidden" name="Action" value="">
        <div class="ui buttons">
            <a href="?"><div class="ui  button">Cancel</div></a>
            <div class="or"></div>
            <div id="action-add-button" class="ui orange button" onclick="submit_add_data();">Add All</div>
        </div>
    </div>
    
    </form>
